import Vue from "vue";
import VueRouter from "vue-router";

// 登录
import login from "@/views/login";
// 首页
import index from "@/views/index";
//注册
import register from "@/views/register";

/**
 *内部页面
 */
import home from "@/views/child/home";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: {
      name: "login"
    }
  },
  {
    path: "/login",
    name: "login",
    component: login,
    meta: {
      requireAuth: false
    }
  },
  {
    path: "/register",
    name: "register",
    component: register,
    meta: {
      requireAuth: false
    }
  },
  {
    path: "/index",
    name: "index",
    component: index,
    children: [
      {
        path: "/home",
        name: "home",
        component: home,
        meta: {
          requireAuth: true
        }
      }
    ]
  }
];

const router = new VueRouter({
  routes
});

export default router;
